home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / os2tools / bnklysrc / b_flofil.c < prev    next >
Text File  |  1989-07-08  |  6KB  |  215 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                            */
  3. /*                                                                            */
  4. /*        ------------         Bit-Bucket Software <no-Inc>                    */
  5. /*        \ 10001101 /         Writers and Distributors of                    */
  6. /*         \ 011110 /          No-Cost<no-tm> Software.                        */
  7. /*          \ 1011 /                                                            */
  8. /*           ------                                                            */
  9. /*                                                                            */
  10. /*    Copyright (C) 1987, 1988, 1989 by Robert Hartman and Vincent Perriello    */
  11. /*                                                                            */
  12. /*                                                                            */
  13. /*                      BinkleyTerm .FLO file Processor                        */
  14. /*                                                                            */
  15. /*                                                                            */
  16. /*      For complete    details  of the licensing restrictions, please refer    */
  17. /*      to the License  agreement,  which  is published in its entirety in    */
  18. /*      the MAKEFILE and BT.C, and also contained in the file LICENSE.210.    */
  19. /*                                                                            */
  20. /*      USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  21. /*      BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  22. /*      THIS    AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,    OR IF YOU DO    */
  23. /*      NOT HAVE THESE FILES,  YOU SHOULD  IMMEDIATELY CONTACT THE AUTHORS    */
  24. /*      AT THE  ADDRESSES LISTED BELOW.  IN NO EVENT SHOULD YOU PROCEED TO    */
  25. /*      USE    THIS  FILE    WITHOUT  HAVING   ACCEPTED    THE  TERMS    OF     THE    */
  26. /*      BINKLEYTERM  LICENSING AGREEMENT,  OR SUCH OTHER    AGREEMENT AS YOU    */
  27. /*      ARE ABLE TO REACH WITH THE AUTHORS.                                    */
  28. /*                                                                            */
  29. /*                                                                            */
  30. /*      The Authors can be reached at the following addresses:                */
  31. /*                                                                            */
  32. /*      Robert C. Hartman                      Vincent E. Perriello            */
  33. /*      Spark Software                         VEP Software                    */
  34. /*      427-3 Amherst Street                     111 Carroll Street             */
  35. /*      CS2032, Suite 232                      Naugatuck, CT 06770            */
  36. /*      Nashua, NH 03061                                                        */
  37. /*                                                                            */
  38. /*      FidoNet 1:132/101                      FidoNet 1:141/491                */
  39. /*      Data      (603) 888-8179                 Data     (203) 729-7569         */
  40. /*                                                                            */
  41. /*      Please feel free to contact us at any time to share your comments     */
  42. /*      about our software and/or licensing policies.                         */
  43. /*                                                                            */
  44. /*                                                                            */
  45. /*--------------------------------------------------------------------------*/
  46.  
  47. #include <signal.h>
  48. #include <ctype.h>
  49. #include <io.h>
  50. #include <conio.h>
  51. #include <string.h>
  52.  
  53. #define WAZOO_SECTION
  54. #include "com.h"
  55. #include "xfer.h"
  56. #include "zmodem.h"
  57. #include "keybd.h"
  58. #include "sbuf.h"
  59. #include "sched.h"
  60. #include "externs.h"
  61. #include "prototyp.h"
  62.  
  63. #define rb_plus "r+b"
  64.  
  65. extern int WaZOO_callback (char *);
  66. static int fsent;
  67.  
  68. #define NUM_FLAGS 4
  69.  
  70.  
  71. /*--------------------------------------------------------------------------*/
  72. /* do_FLOfile (send files listed in .FLO files)                             */
  73. /*     returns TRUE (1) for good xfer, FALSE (0) for bad                        */
  74. /*--------------------------------------------------------------------------*/
  75. int do_FLOfile (ext_flags,callback)
  76. char *ext_flags;
  77. int (*callback)(char *);
  78. {
  79.    FILE *fp;
  80.    char fname[80];
  81.    char s[80];
  82.    char *sptr;
  83.    char *HoldName;
  84.    int c;
  85.    int i,j;
  86.    struct stat buf;
  87.  
  88.    long current, last_start;
  89.  
  90.    HoldName = HoldAreaNameMunge(called_zone);
  91.  
  92.    /*--------------------------------------------------------------------*/
  93.    /* Send files listed in ?LO files (attached files)                     */
  94.    /*--------------------------------------------------------------------*/
  95.    for (c = 0; c < strlen (ext_flags); c++)
  96.       {
  97. #ifndef JACK_DECKER
  98.       if (caller && (ext_flags[c] == 'H'))
  99.          continue;
  100. #endif
  101.  
  102.       sprintf (fname, "%s%04x%04x.%cLO",
  103.                HoldName, called_net, called_node, ext_flags[c]);
  104.       errno = 0;
  105.  
  106.       if (!stat (fname, &buf))
  107.          {
  108.          errno = 0;
  109.          fp = fopen (fname, rb_plus);
  110.          if (got_error (OPEN_msg, fname))
  111.             {
  112.             continue;
  113.             }
  114.  
  115.          current = 0L;
  116.          while (!feof (fp))
  117.             {
  118.             s[0] = 0;
  119.             last_start = current;
  120.             fgets (s, 79, fp);
  121.             if (got_error (READ_msg, fname))
  122.                s[0] = 0;
  123.  
  124.             sptr = s;
  125.  
  126.             for (i = 0; sptr[i]; i++)
  127.                if (sptr[i] <= ' ')
  128.                   sptr[i] = 0;
  129.  
  130.             current = ftell (fp);
  131.  
  132.             if (sptr[0] == TRUNC_AFTER)
  133.                {
  134.                sptr++;
  135.                i = TRUNC_AFTER;
  136.                }
  137.             else if (sptr[0] == SHOW_DELETE_AFTER)
  138.                {
  139.                sptr++;
  140.                i = SHOW_DELETE_AFTER;
  141.                }
  142.             else i = NOTHING_AFTER;
  143.  
  144.             if (!sptr[0])
  145.                {
  146.                continue;
  147.                }
  148.  
  149.             if (sptr[0] != '~')
  150.                {
  151.                if (stat (sptr, &buf))             /* file exist? */
  152.                   {
  153.                   got_error (FIND_msg, sptr);
  154.                   continue;
  155.                   }
  156.                else if (!buf.st_size)
  157.                   {
  158.                   continue;                      /* 0 length? */
  159.                   }
  160.  
  161.                if (!(j = (*callback) (sptr)))
  162.                   {
  163.                   fclose (fp);
  164.                   net_problems = 1;
  165.                   return FALSE;
  166.                   }
  167.  
  168.                /*--------------------------------------------*/
  169.                /* File was sent.  Flag file name             */
  170.                /*--------------------------------------------*/
  171.                fseek (fp, last_start, SEEK_SET);
  172.                putc ('~', fp);                   /* flag it */
  173.                fflush (fp);
  174.                rewind (fp);                      /* clear any eof flags */
  175.                fseek (fp, current, SEEK_SET);
  176.                errno = 0;
  177.  
  178.                if (j == SPEC_COND)                 /* if "Funny" success,   */
  179.                   continue;                      /* don't delete/truncate */
  180.  
  181.                if (i == TRUNC_AFTER)
  182.                   {
  183.                   CLEAR_IOERR ();
  184.                   i = open (sptr, O_WRONLY|O_TRUNC, S_IWRITE);      /*PLF Wed  06-14-1989  23:59:51 */
  185.                   got_error (TRUNC_msg, sptr);
  186.                   status_line (FLAGGING_msg, sptr);
  187.                   close (i);
  188.                   }
  189.                else if (i == SHOW_DELETE_AFTER)
  190.                   {
  191.                   CLEAR_IOERR ();
  192.                   unlink (sptr);
  193.                   got_error (UNLINK_msg, sptr);
  194.                   status_line (UNLINKING_msg, sptr);
  195.                   }
  196.                else if (i == DELETE_AFTER)
  197.                   {
  198.                   CLEAR_IOERR ();
  199.                   unlink (sptr);
  200.                   got_error (UNLINK_msg, sptr);
  201.                   }
  202.                }
  203.             }                                     /* while */
  204.  
  205.          errno = 0;
  206.          fclose (fp);
  207.          got_error (CLOSE_msg, fname);
  208.          unlink (fname);
  209.          errno = 0;
  210.          }                                         /* !stat */
  211.       }                                          /* for */
  212.  
  213.    return TRUE;
  214. }
  215.